package com.demo.common;

import com.demo.controller.IndexController;
import com.demo.controller.NewsController;
import com.demo.controller.UserController;
import com.demo.models.News;
import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.core.JFinal;
import com.jfinal.kit.PropKit;

public class DemoConfig extends JFinalConfig {

	@Override
	public void configConstant(Constants me) {
		PropKit.use("a_little_config.txt");
		me.setDevMode(PropKit.getBoolean("devMode", false));

	}

	@Override
	public void configRoute(Routes me) {
		me.add("/", IndexController.class, "/index");
		me.add("/news", NewsController.class, "/index");
		me.add("/user", UserController.class, "/user");
	}

	@Override
	public void configPlugin(Plugins me) {
		// C3p0Plugin cp = new C3p0Plugin(PropKit.get("jdbcUrl"),
		// PropKit.get("user"), PropKit.get("password"));
		// me.add(cp);
		// ActiveRecordPlugin arp = new ActiveRecordPlugin(cp);
		// me.add(arp);
		// arp.addMapping("article", News.class);
	}

	@Override
	public void configInterceptor(Interceptors me) {
		// TODO Auto-generated method stub

	}

	@Override
	public void configHandler(Handlers me) {
		// TODO Auto-generated method stub

	}

	@Override
	public void afterJFinalStart() {
		News.me.init();
	}

	public static void main(String[] args) {
		JFinal.start("WebRoot", 8009, "/", 5);
	}

}
